ng-book 2 by Felipe Coury Ari Lerner Nate Murray && Carlos Taborda
Author:Felipe Coury, Ari Lerner, Nate Murray, && Carlos Taborda
Language: eng
Format: mobi
Publisher: leanpub.com
Published: 2016-09-02T04:00:00+00:00
One other detail, since we’re already looking that the messages for the current thread, this is a convenient area to mark these messages as read.
code/rxjs/chat/app/ts/services/ThreadsService.ts 54 return _.chain(messages) 55 .filter((message: Message) => 56 (message.thread.id === currentThread.id)) 57 .map((message: Message) => { 58 message.isRead = true; 59 return message; }) 60 .value();
Whether or not we should be marking messages as read here is debatable. The biggest drawback is that we’re mutating objects in what is, essentially, a “read” thread. i.e. this is a read operation with a side effect, which is generally a Bad Idea. That said, in this application the currentThreadMessages only applies to the currentThread and the currentThread should always have its messages marked as read. That said, the “read with side-effects” is not a pattern I recommend in general.
Putting it together, here’s what currentThreadMessages looks like:
code/rxjs/chat/app/ts/services/ThreadsService.ts 50 this.currentThreadMessages = this.currentThread 51 .combineLatest(messagesService.messages, 52 (currentThread: Thread, messages: Message[]) => { 53 if (currentThread && messages.length > 0) { 54 return _.chain(messages) 55 .filter((message: Message) => 56 (message.thread.id === currentThread.id)) 57 .map((message: Message) => { 58 message.isRead = true; 59 return message; }) 60 .value(); 61 } else { 62 return []; 63 } 64 });
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12589)
Hello! Python by Anthony Briggs(9926)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9800)
The Mikado Method by Ola Ellnestam Daniel Brolund(9786)
Dependency Injection in .NET by Mark Seemann(9347)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7771)
Grails in Action by Glen Smith Peter Ledbrook(7704)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7566)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7152)
Microservices with Go by Alexander Shuiskov(6915)
Practical Design Patterns for Java Developers by Miroslav Wengner(6833)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6774)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Angular Projects - Third Edition by Aristeidis Bampakos(6191)
The Art of Crafting User Stories by The Art of Crafting User Stories(5711)
NetSuite for Consultants - Second Edition by Peter Ries(5642)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5453)
Kotlin in Action by Dmitry Jemerov(5073)
